 
  
    layui.use(['icheck','element',"laytpl",'laypage','form','laydate'], function() {
        var $ = layui.jquery,
        layer = layui.layer,
        laytpl = layui.laytpl,
        laypage = layui.laypage;
        var form = layui.form();
        var tjstate =0;
      
       
        
     
	    form.render(); 
/*	    
	    var pageNo = $("#pageNo").val();
    	var totalPage = $("#totalPage").val();
    	
    	//分页按钮
    	laypage({
            cont: 'page',
            curr: pageNo//'${pager.pageNo}'
            ,pages: totalPage//'${pager.totalPages}' //总页数
            ,
            groups: 5 //连续显示分页数
            ,
            skip: true,
            jump: function(obj, first) {
                //得到了当前页，用于向服务端请求对应数据
                var curr = obj.curr;
                if(!first) {
                	$("#skipToPage").val(curr);
                	$("#customerlistform").submit();
                }
            }
        }); 
    	*/
 
    	  
     
    	$(".searchbtnclean").on("click",function(){
    		$("#keyWord").val("");
    		$("#province").val("");
    		$("#address").val("");
    		$("#city").html("<option value=\"\">请选择市</option>");
		    $("#city").val("");
		    $("#category").val("");
		    $("#zizhiType").val("");
    	});
    	 
 
        //点击搜索
    	$(".customersearchbtn").on("click",function(){
    		var ky = $.trim($("#keyWord").val());
       	    $("#keyWord").val(ky);
       	    $("#skipToPage").val(1);
    		$(".customersearcheform").submit();
    	});
    	
    	
    	
    	
    	   //修改跟进记录
    	$(".updbtn").on("click",function(){
    		   var id =  $(this).attr("data");
    		   $.ajax({
           		type : "post",
           		url : "/customer/qualificationiteminfo",
           		data : {id:id},
           		dataType : "json",
           		success : function(data){
           			  var id = data.id;  
           		    	$("#updremark").val(data.content);
		           	  layer.open({
				             type:1,
				             content:$('.updlgjjl'),
				             btn:['确定','取消'],
				             btnAlign:'c',
				             shadeClose:false,
				             title:'修改跟进记录',
				             area:['600px','450px'],
				             maxWidth:800,
				             yes: function(layero, index){
				             	    var content  = $("#updremark").val();
				             	    if(content.length<1){
				             	    	layer.tips("请填写跟进记录", $("#updremark"), {
				         					tips: [2,tipColor],
				         	     		 tipsMore: true
				         	     		});
				             	    	return false;
				             	    }
				             	    
				                 	$.ajax({
				                 		type : "post",
				                 		url : "/customer/updatequalificationitem",
				                 		data : {id:id,content:content},
				                 		dataType : "json",
				                 		success : function(data){
				                 			if (data == 1) {
				                 				layer.closeAll();
				                 				layer.msg("修改跟进记录成功",{icon: 1},function(){
				                 					window.location.reload();
				                 				});
				                 			}else { 
				                 				layer.msg("修改跟进记录失败",{icon: 2});
				                 			}
				                 		}
				                 	});
				             }
				        });
           			
           		}
           	});
    	});
    	
    	   //删除跟进记录
    	$(".scbtn").on("click",function(){
    		   var id =  $(this).attr("data");
    		   layer.confirm('确定删除该跟进记录？', function(index){
    			   layer.close(index);
    			   $.ajax({
                		type : "post",
                		url : "/customer/delqualificationitem",
                		data : {id:id},
                		dataType : "json",
                		success : function(data){
                			if (data == 1) {
                				layer.msg("删除成功",{icon: 1},function(){
                					window.location.reload();
                				});
                			} else { 
                				layer.msg("删除失败",{icon: 2});
                			}
                		}
                	});
    		   }); 
    	});
    	   //添加跟进记录
    	$(".gjjlbtn").on("click",function(){
    		   var cusid =  $("#cusid").val();
		       	 layer.open({
		             type:1,
		             content:$('.addlgjjl'),
		             btn:['确定','取消'],
		             btnAlign:'c',
		             shadeClose:false,
		             title:'新增跟进记录',
		             area:['600px','450px'],
		             maxWidth:800,
		             yes: function(layero, index){
		             	    var content  = $("#remark").val();
		             	    if(content.length<1){
		             	    	layer.tips("请填写跟进记录", $("#remark"), {
		         					tips: [2,tipColor],
		         	     		 tipsMore: true
		         	     		});
		             	    	return false;
		             	    }
		                 	$.ajax({
		                 		type : "post",
		                 		url : "/customer/savequalificationitem",
		                 		data : {cusid:cusid,content:content},
		                 		dataType : "json",
		                 		success : function(data){
		                 			if (data == 1) {
		                 				layer.closeAll();
		                 				layer.msg("新增跟进记录成功",{icon: 1},function(){
		                 					window.location.reload();
		                 				});
		                 			} else { 
		                 				layer.msg("新增跟进记录失败",{icon: 2});
		                 			}
		                 		}
		                 	});
		             }
		        });
    	});
    	

    	
    
    });
	
 
 
